extends CanvasLayer

@onready var animation := $AnimationPlayer
@onready var interact_button := $MarginContainer/VBoxContainer/HBoxContainer2/InteractButton

func _ready() -> void:
	EventBus.show_interaction_prompt.connect(show_interaction_prompt)
	EventBus.hide_interaction_prompt.connect(hide_interaction_prompt)

func show_interaction_prompt() -> void:
	animation.play("show_interaction_prompt")

func hide_interaction_prompt() -> void:
	animation.play("hide_interaction_prompt")

func _on_reload_button_pressed() -> void:
	EventBus.player_died.emit() #workaround

func _on_interact_button_pressed() -> void:
	if interact_button.modulate == Color(1, 1, 1, 1):
		var event = InputEventKey.new()
		event.keycode = KEY_E
		event.pressed = true
		Input.parse_input_event(event)
